<form th:action="${url}" class="form-horizontal" th:object="${ct}" style="margin-right: 20px" id="sele_temp_form" method="post" th:fragment="template(url)">
<div class="box-body">
	<div class="form-group">
		<label for="area.id" class="col-sm-1 control-label">地区</label>
		<div class="col-sm-2">
			<select th:field="*{area}" class="form-control">
			  <option th:each="area : ${areas}" th:value="${area.code}" th:text="${area.name}"></option>
			</select>
		</div>
		<label for="company.id" class="col-sm-1 control-label company_div">公司名</label>
		<div class="col-sm-2 company_div">
			<select th:field="*{company.id}" class="form-control">
			  <option th:each="company : ${companys}" th:value="${company.id}" th:text="${company.name}"></option>
			</select>
		</div>
		<label for="bigClass" class="col-sm-1 control-label">业务类型</label>
		<div class="col-sm-2">
			<select th:field="*{bigClass}" class="form-control">
			  <option th:each="cls : ${bigClasses}" th:value="${cls[0]}" th:text="${cls[1]}"></option>
			</select>
		</div>
		<label for="smallClass" class="col-sm-1 control-label">业务名称</label>
		<div class="col-sm-2">
			<select th:field="*{smallClass}" class="form-control">
				<option th:each="cls : ${smallClasses}" th:value="${cls[0]}" th:text="${cls[1]}"></option>
			</select>
		</div>
	</div>
	<div class="form-group">
		<label for="ycfq" class="col-sm-2 control-label">是否有附加条款</label>
		<div class="col-sm-2">
			<label class="radio-inline">
				<input type="radio" th:field="*{hasFjtk}" value="1" data-rule-required="true" > 有
			</label>
			<label class="radio-inline">
				<input type="radio" th:field="*{hasFjtk}" value="0" data-rule-required="true" > 无
			</label>
		</div>
		<label for="ycfq" class="col-sm-2 control-label ycfq_div">一次/分期</label>
		<div class="col-sm-2 ycfq_div">
			<label class="radio-inline">
				<input type="radio" th:field="*{ycfq}" value="O" data-rule-required="true" > 一次
			</label>
			<label class="radio-inline">
				<input type="radio" th:field="*{ycfq}" value="T" data-rule-required="true" > 分期
			</label>
		</div>
		<label for="isHjb" class="col-sm-2 control-label ishjb_div">是否为宏金保</label>
		<div class="col-sm-2 ishjb_div">
			<label class="radio-inline">
				<input type="radio" th:field="*{isHjb}" value="1" data-rule-required="true" > 是
			</label>
			<label class="radio-inline">
				<input type="radio" th:field="*{isHjb}" value="0" data-rule-required="true" > 否
			</label>
		</div>
		
	</div>
</div>

<div class="box-footer" >
	<div>
		<button type="button" class="btn btn-primary pull-right" style="width: 200px" onclick="form_submit()">下一步</button> 
	</div>
</div>
<script>
$(function() {
	set_visibility();
	
	$("#area").change(function(){
		change_big_class();
	});
	
	function change_big_class() {
		var area = $("#area").val();
		if(area == 'B' || area == 'C') {
			$(".company_div").css("visibility", 'hidden');
		} else {
			$(".company_div").css("visibility", 'visible');
		}
		$.post("[[@{/contract/big/class}]]", {area: area}, function(ret) {
			$("#bigClass").empty();
			$(ret).each(function(i, val){
				$('<option value="' + val[0] + '">' + val[1] + '</option>').appendTo($("#bigClass"));
			});
			change_small_class();
		}, "json");
	}
	$("#bigClass").change(function(){
		change_small_class();
	});
	function change_small_class() {
		var id = $("#bigClass").val();
		$.post("[[@{/contract/small/class}]]", {id: id}, function(ret) {
			$("#smallClass").empty();
			$(ret).each(function(i, val){
				$('<option value="' + val[0] + '">' + val[1] + '</option>').appendTo($("#smallClass"));
			});
			set_visibility();
			$('input:radio[name=ycfq]')[0].checked = true;
			$('input:radio[name=isHjb]')[1].checked = true;
			
		}, "json");
	}
	$("#smallClass").change(function(){
		set_visibility();
		
	})
	function set_visibility() {
		var ids = $("#smallClass").val().split('_');
		$(".ycfq_div").css("visibility", ids[1] == '1' ? 'visible' : 'hidden');
		$(".ishjb_div").css("visibility", ids[2] == '1' ? 'visible' : 'hidden');
	}
});
</script>
</form>

